package com.exam.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exam.entity.ExamQuestion;
import com.exam.mapper.ExamQuestionMapper;
import com.exam.service.ExamQuestionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author 小聋包
 * @date 2024-04-29 16:48
 * @Version 1.0
 */
@Service
@RequiredArgsConstructor
public class ExamQuestionServiceImpl extends ServiceImpl<ExamQuestionMapper, ExamQuestion> implements ExamQuestionService {
    private final ExamQuestionMapper examQuestionMapper;


    /**
     * 根据考试ID获取考试题目
     *
     * @param examId 考试ID
     * @return 考试题目
     */
    @Override
    public ExamQuestion getExamQuestionByExamId(Integer examId) {
        // 调用examQuestionMapper的selectOne方法，传入一个QueryWrapper对象作为参数
        // QueryWrapper对象通过eq方法设置条件，即exam_id等于传入的examId
        return examQuestionMapper.selectOne(new QueryWrapper<ExamQuestion>().eq("exam_id", examId));
    }

}
